import https from "../https/Https.js";
var searcher = {
	CH_XSO : "xso", //销售单据
	CH_CGO : "cgo", //采购单据；
	CH_YYO : "yyo",//预约单据
	CH_GD : "gd",//产品
	CH_XM : "xm",//服务
	CH_CUSTOM  : "custom",//客户
	CH_SUPP : "supp",//供应商
	CH_BILL : "bill",//供应商
	CH_BILL_YY : "bill_yy",//收款搜索-预约
	CH_BILL2 : "bill2",//付款搜索
	
	
	gdsObjTypeList:[],//产品搜索列表
	gdsCatList:[],//产品搜索分类列表
	billObjTypeList:[],//单据搜索类型列表
	
	customTypeList:[],//
	customCatList:[],//
	
	suppTypeList:[],//
	suppCatList:[],//
	
};

/***产品搜索分类列表包含数量**BEGIN***/
searcher.loadGdsSchObjTypeLs = async function(ch)
{
	let data = {};
	let that = this;
	data.ch = ch;//场景，xso=销售单据；cgo=采购单据；yyo=预约单据；gd 产品；xm: 服务；custom 客户；supp供应商；bill收款搜索-销售；bill_yy收款搜索-预约；bill2付款搜索
	let res = await https.searchObjType(data,callBack);
	function callBack(data)
	{
		if(data && data.status == 1)
		{
			if(!data.data)return;
			data = data.data;
			if(ch == that.CH_GD)
			{
				if(data.cat_ls)
					that.gdsCatList = data.cat_ls;
				if(data.es_ls)
					that.gdsObjTypeList = data.es_ls;
			}
			else if(ch == that.CH_CUSTOM)
			{
				if(data.cat_ls)
					that.customCatList = data.cat_ls;
				if(data.es_ls)
					that.customTypeList = data.es_ls;
			}
			else if(ch == that.CH_SUPP)
			{
				if(data.cat_ls)
					that.suppCatList = data.cat_ls;
				if(data.es_ls)
					that.suppTypeList = data.es_ls;
				// console.log("that.supplist============:",that.suppTypeList);
			}
			else if(ch == that.CH_XM)
			{
				if(data.cat_ls)
					that.projectCatList = data.cat_ls;
				if(data.es_ls)
					that.projectTypeList = data.es_ls;
				// console.log("that.supplist============:",that.suppTypeList);
			}
			
		}
	}
}

searcher.getGdsObjTypeList = function()
{
	return this.gdsObjTypeList;
}

searcher.getCatList = function()
{
	return this.gdsCatList;
}

/****客户搜索****/
searcher.getCoutomTypeList = function()
{
	return this.customTypeList;
}

searcher.getCustomCatList = function()
{
	return this.customCatList;
}

/*****供应商搜索*****/
searcher.getSuppTypeList = function()
{
	return this.suppTypeList;
}

searcher.getSuppCatList = function()
{
	return this.suppCatList;
}
// 服务搜索
searcher.getProjectTypeList = function()
{
	return this.projectTypeList;
}
searcher.getProjectCatList = function()
{
	return this.projectCatList;
}
/***产品搜索分类列表包含数量**END***/

/****销售搜索单据**BEGIN***/
searcher.loadBillSchObjTypeLs = async function(ch)
{
	let that = this;
	let data = {};
	data.ch = ch;
	let res = https.searchObjType(data,callBack);
	function callBack(data)
	{
		// console.log("搜索单据=that.billObjTypeList==：",that.billObjTypeList);
		if(data && data.status == 1)
		{
			if(!data.data)return;
			if(!data.data.es_ls)return;
			that.billObjTypeList = data.data.es_ls;
		}
	}
}

searcher.getBillSearObjTypeList = function()
{
	return this.billObjTypeList;
}
/****销售搜索单据**END***/


export default searcher;
